import UIBase from "../core/UIBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class TipMessage extends UIBase {
    
    @property({ type: cc.Node, tooltip: CC_DEV && '背景遮罩' })
    public background: cc.Node = null;

    @property(cc.Label)
    label: cc.Label = null;

    init() {
    }

    public show(msg:string=''){
        this.node.setPosition(cc.v3(0,0,0));
        this.label.string = msg;
        cc.tween(this.node)
                .by(1.5, { position: new cc.Vec3(0, 100, 0) }, { easing: 'quadOut' })
                .delay(0.2)
                .to(0.2, { opacity: 0 })
                .call(() => {
                    this.destroy();
                })
                .start();
    }

}
